var core = require('./core');
var config = require('../config.json');
var mongoService = require('./mongodb');
var sqliteService = require('./sqlite');

module.exports = function (callback) {
  var service = null;
  if (config.store.target === 'mongodb') {
    service = mongoService;
  } else if (config.store.target === 'sqlite') {
    service = sqliteService;
  } else {
    throw new Error('Config ERROR');
  }
  service.readDict(function (err, data) {
    if(err) console.error(err);
    else core.init(data);
    callback();
  });
};